package master.userInterface;

import gates.QuantumGate;

import javax.swing.*;

import master.QuantumNetwork;
import master.event.NetworkEvent;
import master.event.NetworkEventListener;

public class NetworkComboBox extends JComboBox implements NetworkEventListener{
	QuantumNetwork myNetwork;//the network this box displays
	public NetworkComboBox(QuantumNetwork myNetwork){
		this.myNetwork = myNetwork;
		myNetwork.addNetworkListener(this);
		resetItems();
	}
	private void resetItems(){
		this.removeAllItems();
		if(myNetwork.getGates() != null)
			for(QuantumGate g : myNetwork.getGates()){
				this.addItem(g.toString());
			}
	}
	public void networkEvent(NetworkEvent e) {
		resetItems();
	}
}
